package demo.practice.leetcode_msjd;

import java.util.Stack;

public class M0206 {

    public boolean isPalindrome(ListNode head) {
        Stack<ListNode> stack= new Stack<>();
        if(head==null)
            return true;
        ListNode cur=head;
        while (cur!=null){
            stack.push(cur);
            cur=cur.next;
        }

        cur=head;
        while (cur!=null){
            if(cur.val!=stack.pop().val)
                return false;
            cur=cur.next;
        }
        return true;
    }
}
